﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;

namespace MyToolConsoleApplication
{
    //生成形如"<input type='text' id='xxx' name='xxx' />"
    class _20120729_MakeHtmlInputEleCode
    {
        static void Main(string[] args)
        {
            List<string> context_list = new List<string>();

            try
            {
                Console.WriteLine("请输入txt文件路径...");
                using (StreamReader sr = new StreamReader(Console.ReadLine()))
                {
                    Console.WriteLine("文件内的内容为...");
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        context_list.Add(line);
                        Console.WriteLine(line);
                    }
                    Console.WriteLine("结束...");
                    Console.WriteLine();
                }

                Regex regex = new Regex(@"(?<fieldName>[A-Z_]+)(\s+)(?<fieldDesc>.+)");

                string format = "<input type='text' id='x_MRTG_{0}' name='x_MRTG_{0}' />";

                foreach (var sdf in context_list)
                {
                    Match match = regex.Match(sdf);
                    //Console.WriteLine(match.Groups["fieldName"].Value);
                    Console.WriteLine(string.Format(format, match.Groups["fieldName"].Value));
                }


            }
            catch (System.Exception ex)
            {
                Console.Write(ex.Message);
            }


            Console.ReadLine();
        }
    }
}
